package com.bwie.es.controller;

import com.bwie.common.domain.Car;
import com.bwie.common.domain.request.CarVO;
import com.bwie.common.result.PageResult;
import com.bwie.common.result.Result;
import com.bwie.es.service.Esservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/es")
public class EsController {
    @Autowired
    private Esservice esservice;

    @PostMapping("/bathAdd")
    public Result bathAdd(@RequestBody List<Car> cars){
        esservice.batchAdd(cars);
        return Result.success();
    }

    @PostMapping("/search")
    public Result<PageResult<Car>> search(@RequestBody CarVO carVO){
        Result<PageResult<Car>> result = esservice.search(carVO);
        return result;
    }

}
